package com.java复习.jdbc.游戏.demo3;

//import javax.jws.soap.SOAPBinding;

/**
 * 角色类
 */
public class User {

    private int id;
    private String name;
    private String account;
    private String password;
    private int ATK;
    private int DEF;
    private int MP;
    private int HP;
    private int money;

    public User(int id, String name, String account, String password, int ATK, int DEF, int MP, int HP, int money) {
        this.id = id;
        this.name = name;
        this.account = account;
        this.password = password;
        this.ATK = ATK;
        this.DEF = DEF;
        this.MP = MP;
        this.HP = HP;
        this.money = money;
    }

    public User() {
    }

    public int  play(User user){
        int oldHP = user.getHP();
        int oldHP1 = this.HP;
        while(true){
            System.out.println("【"+this.name+"】:使用平A");
            if(this.ATK>user.getDEF()){
                System.out.println("【"+user.getName()+"】:受到"+(this.ATK-user.getDEF())+"点伤害，剩余："+(user.getHP()-this.ATK-user.getDEF())+"HP");
                user.setHP( user.getHP()-this.ATK-user.getDEF());
            }else{
                System.out.println("【"+user.getName()+"】:受到1点伤害，剩余："+(user.getHP()-1)+"HP");
                user.setHP( user.getHP()-1);
            }
            if(user.getHP()<=0){
                System.out.println("【"+user.getName()+"】：被打死了");
                user.setHP(oldHP);
                return 0;
            }
            System.out.println("【"+user.name+"】:使用平A");
            if(user.getATK()>this.DEF){
                System.out.println("【"+this.name+"】:受到"+(user.getATK()-this.DEF)+"点伤害，剩余："+(this.HP-user.getATK()-this.DEF)+"HP");
                this.HP=this.HP-user.getATK()-this.DEF;
            }else{
                System.out.println("【"+name+"】:受到1点伤害，剩余："+(this.HP-1)+"HP");
                this.HP = this.HP-1;
            }
            if(this.HP<=0){
                System.out.println("【"+this.name+"】：被打死了");
                this.HP = oldHP1;
                return 1;
            }
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getATK() {
        return ATK;
    }

    public void setATK(int ATK) {
        this.ATK = ATK;
    }

    public int getDEF() {
        return DEF;
    }

    public void setDEF(int DEF) {
        this.DEF = DEF;
    }

    public int getMP() {
        return MP;
    }

    public void setMP(int MP) {
        this.MP = MP;
    }

    public int getHP() {
        return HP;
    }

    public void setHP(int HP) {
        this.HP = HP;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", account='" + account + '\'' +
                ", password='" + password + '\'' +
                ", ATK=" + ATK +
                ", DEF=" + DEF +
                ", MP=" + MP +
                ", HP=" + HP +
                ", money=" + money +
                '}';
    }
}
